﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Web;

/// <summary>
/// taskList 的摘要说明
/// </summary>
public class gameList : BaseClass
{
    string tableName = "gameList";
    public gameList()
    {
        //
        // TODO: 在此处添加构造函数逻辑
        //
    }

    /// <summary>
    /// 分页查询
    /// </summary>
    /// <param name="pageSize">每页数</param>
    /// <param name="pageIndex">当前第多少页</param>
    /// <param name="count">数据总数</param>
    /// <param name="where">查询条件</param>
    /// <returns></returns>
    public ArrayList GetList(int pageSize, int pageIndex, out int count, string where, Hashtable h_where)
    {
        //用户表
        string sqlcount = "select count(0) from " + tableName + " where 1 = 1 " + where;
        string sql = string.Format("select top {0} * from " + tableName + " where 1 = 1 {2} and ID not in(select top {1} id from " + tableName + " where 1 = 1 {2} order by id desc)order by id desc;"
              , pageSize, (pageIndex - 1) * pageSize, where);
        ArrayList data = new SQLHelper("getnum").Select(sql, h_where);
        count = Convert.ToInt32(new SQLHelper("getnum").ExecuteScalar(sqlcount, h_where));
        return data;
    }

    public ArrayList GetList()
    {
        //用户表
        string sql = string.Format("select * from " + tableName + " where 1 = 1");
        return new SQLHelper("getnum").Select(sql);

    }
    /// <summary>
    /// 新增一条
    /// </summary>
    /// <param name="n">参数</param>
    /// <param name="TableName">表名</param>
    /// <returns></returns>
    public int Insert(Hashtable n)
    {
        return BaseInsert(n, tableName);
    }

    /// <summary>
    /// 更新一条
    /// </summary>
    /// <param name="n"></param>
    /// <returns></returns>
    public int Update(Hashtable n)
    {
        return BaseUpdate(n, tableName);
    }

    public int Delete(string id)
    {
        return BaseDelete(id, tableName);
    }
    public int DeleteBatch(string ids)
    {
        return BaseDeleteBatch(ids, tableName);
    }
    /// <summary>
    /// 任何条件查询一条
    /// </summary>
    /// <param name="n"></param>
    /// <returns></returns>
    public Hashtable GetModel(Hashtable n)
    {
        return BaseGetModel(n, tableName);
    }
    public int SelectOneRowData(string a)
    {
        Hashtable h = new Hashtable();
        h["a"] = a;
        string sql = "select count(*) from " + tableName + " where a = @a";
        return Convert.ToInt32(new SQLHelper("getnum").ExecuteScalar(sql, h));
    }
    public int DeleteAll()
    {
        string sql = "delete from " + tableName;
        return new SQLHelper("getnum").Execute(sql);
    }
}